{template 'common/header-storex'}
<div class="wn-main">
	<div class="wn-main__head">商品管理 / 维护房价</div>
	<div class="wn-main__content">
		<div class="wn-tabs">
			<div class="wn-tabs__item">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_goodsmanage', array('op' => 'display', 'storeid' => $_GPC['storeid']))}">商品列表</a>
			</div>
			<div class="wn-tabs__item">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_room_status', array('op' => 'display', 'storeid' => $_GPC['storeid']))}">维护房量/房态</a>
			</div>
			<div class="wn-tabs__item wn-tabs__item--active">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_room_price', array('op' => 'display', 'storeid' => $_GPC['storeid']))}">维护房价</a>
			</div>
			<div class="wn-tabs__item {if $op == 'recycle'}wn-tabs__item--active{/if}">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_goodsmanage', array('op' => 'recycle', 'storeid' => $_GPC['storeid']))}">商品回收站</a>
			</div>
		</div>
		<div class="clearfix"></div>

		<div class="wn-main__search clearfix">
			<div class="wn-main__search__form" style="width: 600px">
				<div class="form-group">
					{php echo tpl_form_field_daterange('datelimit',array('starttime'=>date('Y-m-d', $startime),'endtime'=>date('Y-m-d', $endtime)))}
					<input class="btn btn-default" id="search_button" type="button" value="搜索">
				</div>
			</div>
			<div class="wn-main__search__action">
				<a href="{php echo $this->createWebUrl('shop_room_price', array('op'=>'updatelot','storeid' => $storeid));}" class="btn btn-primary">批量修改房价</a>
			</div>
		</div>

		<div class="panel panel-default wn-panel">
			<div class="panel-heading">
				详细数据 <small>点击价格可以单独修改 <span style="color:red">(修改后的价格是当天购买或者预定的价格)</span></small>
			</div>
			<div class="panel-body table-responsive">
				<div class="sub-content" id="d_list"></div>
			</div>
		</div>
	</div>
		<input type="hidden" id="storeid" value="{$storeid}" />
</div>
<script type="text/javascript">
	$(function () {
		var next_page = 0;
		window.get_list  = function(start, end, page) {
			$("#d_list").html("正在加载...");
			$.post("{php echo $this->createWebUrl('shop_room_price')}", {op: 'getDate', storeid:{$storeid}, page: page, start: start, end: end}, function (data) {
				data = eval("(" + data + ")");
				if (data.result == 1) {
					$("#d_list").html(data.code);
					window.bindEvents();
				}
			});
		}
		//上10天价格
		window.prePage = function(){
			var start = $(":hidden[name='datelimit[start]']").val();
			var end = $(":hidden[name='datelimit[end]']").val();
			window.get_list(start, end, parseInt($("#page").val())-1);
		}
		//后10天价格
		window.nextPage = function(){
			var start = $(":hidden[name='datelimit[start]']").val();
			var end = $(":hidden[name='datelimit[end]']").val();
			window.get_list(start, end, parseInt($("#page").val())+1);
		}
		//绑定修改价格事件
		window.bindEvents = function(){
			$(".price_input").unbind("keydown");
			$(".price_span").click(function(){
				$(".price_editspan").addClass('hide');

				$(".price_span").removeClass('hide');
				var obj =$(this);
				obj.addClass('hide');
				obj.parent().find(".price_editspan").removeClass('hide');
				obj.next().find(".price_input").unbind("keydown");
				obj.next().find(".price_input").val($.trim(obj.html())).select().keydown(function(event){
					if(event.keyCode==13){
						window.submitPrice( $(this) );
					}
				}).blur(function(){
					$(this).parent().parent().find(".price_span").removeClass('hide');
					$(this).parent().addClass('hide');
				});
				Tip.show( obj.next().find(".price_input") , "回车键确定修改","top");
			});
		}
		window.submitPrice = function(input){
			var storeid = input.attr("storeid");
			var roomid = input.attr("roomid");
			var date = input.attr("date");
			var pricetype  = input.attr("pricetype");
			/*if(!input.isNumber()){
				Tip.select(input,"请输入数字!","top");
				return;
			}*/
			var price = $.trim( input.val() );
			input.parent().parent().find(".price_span").html( price ).removeClass('hide');
			input.parent().addClass('hide');
			$.post("{php echo $this->createWebUrl('shop_room_price')}",
				{op: 'submitPrice', storeid:storeid,roomid:roomid,date:date,price: price,pricetype:pricetype}, function (data) {
					data = eval("(" + data + ")");
					if (data.result == 1) {
					}
			});
		}
		$("#search_button").click(function () {
			var start = $(":hidden[name='datelimit[start]']").val();
			var end = $(":hidden[name='datelimit[end]']").val();
			window.get_list(start, end, 1);
		});
		$("#search_button").click();
	});
</script>
	{template 'common/footer'}
